package me.zhengjie.modules.houseshowscenehot.rest;

import me.zhengjie.annotation.Log;
import me.zhengjie.modules.houseshowscenehot.domain.HouseShowSceneHot;
import me.zhengjie.modules.houseshowscenehot.service.HouseShowSceneHotService;
import me.zhengjie.modules.houseshowscenehot.service.dto.HouseShowSceneHotDto;
import me.zhengjie.modules.houseshowscenehot.service.dto.HouseShowSceneHotQueryParam;
import org.springframework.data.domain.Pageable;
import lombok.RequiredArgsConstructor;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.*;
import java.util.Set;

/**
* @author TianI
* @date 2021-12-24
**/
@RestController
@RequiredArgsConstructor
@Api(tags = "HouseShowSceneHotController管理")
@RequestMapping("/api/houseShowSceneHot")
public class HouseShowSceneHotController {

    private final HouseShowSceneHotService houseShowSceneHotService;

    @GetMapping
    @Log("查询HouseShowSceneHotController")
    @ApiOperation("查询HouseShowSceneHotController")
    @PreAuthorize("@el.check('houseShowSceneHot:list')")
    public ResponseEntity query(HouseShowSceneHotQueryParam query, Pageable pageable){
        return new ResponseEntity<>(houseShowSceneHotService.queryAll(query,pageable),HttpStatus.OK);
    }

    @PostMapping
    @Log("新增HouseShowSceneHotController")
    @ApiOperation("新增HouseShowSceneHotController")
    @PreAuthorize("@el.check('houseShowSceneHot:add')")
    public ResponseEntity create(@Validated @RequestBody HouseShowSceneHotDto resources){
        return new ResponseEntity<>(houseShowSceneHotService.insert(resources),HttpStatus.CREATED);
    }

    @PutMapping
    @Log("修改HouseShowSceneHotController")
    @ApiOperation("修改HouseShowSceneHotController")
    @PreAuthorize("@el.check('houseShowSceneHot:edit')")
    public ResponseEntity update(@Validated @RequestBody HouseShowSceneHotDto resources){
        houseShowSceneHotService.updateById(resources);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @DeleteMapping
    @Log("删除HouseShowSceneHotController")
    @ApiOperation("删除HouseShowSceneHotController")
    @PreAuthorize("@el.check('houseShowSceneHot:del')")
    public ResponseEntity delete(@RequestBody Set<Long> ids) {
        houseShowSceneHotService.removeByIds(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }

    /*
    @Log("导出HouseShowSceneHotController")
    @ApiOperation("导出HouseShowSceneHotController")
    @GetMapping(value = "/download")
    @PreAuthorize("@el.check('houseShowSceneHot:list')")
    public void download(HttpServletResponse response, HouseShowSceneHotQueryParam query) throws IOException {
        houseShowSceneHotService.download(houseShowSceneHotService.queryAll(query), response);
    }*/

}
